package tester.outcome;

import messages.BaseMessage;
import messages.observer.EventCollectionMessage;

/**
 * This method is the base outcome that looks for events sent by either the person or group dispatcher
 * @author Caleb Chan
 *
 */
public abstract class BaseEventOutcome extends BaseOutcome {

	/**
	 * BaseEventOutcome constructor
	 * @param startTime The start time of the outcome
	 */
	public BaseEventOutcome(long startTime) {
		super(new EventCollectionMessage(new byte[0]), startTime);
	}
	
	@Override
	public boolean checkOutcome(BaseMessage message) {
		// Checks if message is correct type
		if(message.getMessageType() != outcomeMessage.getMessageType()){
			return false;
		}
		// Checks if the message is the right outcome
		if(checkOutcome((EventCollectionMessage)message)){
			completionTime = System.currentTimeMillis();
			System.out.println(getOutcomeChecksStr() + " has passed");
			return true;
		}
		return false;
	}
	/**
	 * This method will check if the message passed in is the expected message
	 * @param message The message to be checked
	 * @return Returns true if the message is the expected message
	 */
	public abstract boolean checkOutcome(EventCollectionMessage message);
}
